1. Field
The technology described herein relates to occlusion queries in graphics processing, and in particular to advantageous methods and apparatus for performing occlusion queries, particularly in tile-based graphics processing systems.
2. Description of the Related Art
As is known in the art, occlusion queries are used in graphics processing to determine, for example, if an object to be rendered is occluded by other objects or not. This information can then be used, e.g. to modify the rendering process, e.g. by modifying the object to be rendered, to try to make it more efficient. Thus, occlusion queries may be used to measure objects to be displayed and rendered, with the rendering process then being modified based on the occlusion measurements.
The occlusion query process may use, for example, information from a previous frame, information for “true” objects of the render output, information for proxy/dummy test objects, or a combination of these.
As is known in the art, graphics processing is typically carried out by defining a set of primitives (polygons) representing an output, such as a frame to be displayed, to be rendered. Each primitive (polygon) of the render output is usually defined and represented as a set of vertices, with each vertex having associated with it a set of data values for the vertex.
The primitives representing the render output are then usually rasterised to generate a plurality of “fragments” to be processed to generate the render output. As is known in the art, these “fragments” are the discrete graphical entities on which the graphics processing operations (such as rendering) are carried out. Each fragment will correspond to a sampling point or sampling points of the render output and have associated with it the necessary data, such as red, green, blue (RGB) colour values, an alpha (transparency) value, and a depth value, to allow the fragment to be displayed. (Fragments may also be referred to as pixels, although it is not inevitably the case that a given fragment will correspond exactly to a single pixel (picture element) in the final render output that is, e.g., displayed, as post-processing, such as down-scaling, may mean that there is not a one-to-one correspondence between the entities (fragments) that the graphics processing operates on and the, e.g. display, pixels.)
The graphics fragments, once generated, undergo a number of processes to shade them to generate their final, to be displayed, appearance, such as applying textures, blending, etc. It is also usually determined whether a given fragment could be visible in (could contribute to) the final render output or not (or be occluded, e.g. by another object in the output, and so not visible (will not contribute to the final render output)). Such visibility tests can comprise, as is known in the art, a Z (depth) test, a stencil test, a frustrum visibility test, an alpha test and/or a scissor test, etc.
Occlusion queries typically count the number of fragments for a given object or objects that pass these visibility tests (at various stages in the fragment processing). Thus a typical occlusion query comprises counting the potentially visible fragments for an object or objects, and then uses that count to determine if the object(s) is visible, and/or which parts of the object are visible etc.
Occlusion queries can normally be specified as part of the graphics API. Normally the commands to the graphics processor will indicate when an occlusion query is to be started, a set of draw calls that are included in the query, and when the query is to stop. Typically the state information for or associated with a draw call, object, etc., to be rendered indicates whether the draw call, object, etc. is to contribute to a given occlusion query or not.
Occlusion queries are usually specified in graphics specifications. For example, both the Open GL and DirectX graphics specifications require and specify occlusion queries. These specifications specify two types of occlusion queries: Boolean and integer. A Boolean query should return true if any fragment of the test object or objects for the query passes the occlusion test (typically a Z (depth) or stencil test, as discussed above), i.e. could be visible, while an integer query should return the number of fragments of the test object or objects that pass the occlusion test, i.e. that could be visible.
Although Open GL and DirectX, for example, specify what is required for an occlusion query, they do not set out how the occlusion queries should be implemented. The Applicants believe therefore that there is scope for improved techniques for performing occlusion queries, e.g. of the type specified by the Open GL and DirectX specifications.